﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Messaging;
using System.Windows.Navigation;
using IkeCode.WP7.Wakeup.Common;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using IkeCode.WP7.Wakeup.Service;
using IkeCode.WP7.Wakeup.AppModel.Model;

namespace IkeCode.WP7.Wakeup.ViewModel
{
    public class SelectRingtoneViewModel : BaseViewModel
    {
        private readonly IDataService _dataService;
        private readonly INavigationService NavigationService;

        public SelectRingtoneViewModel(IDataService dataService, INavigationService navigationService)
        {
            _dataService = dataService;
            NavigationService = navigationService;
        }

        public override void SetData(object data)
        {
            base.SetData(data);

            _dataService.GetRingtones((obj, error) =>
            {
                RingtoneList = obj;
            });

            PageTitle = "select ringtone";
        }

        #region Properties
        
        private RingtoneModel _selectedRingtone;
        public RingtoneModel SelectedRingtone
        {
            get { return _selectedRingtone; }
            set
            {
                if (_selectedRingtone == value)
                    return;

                _selectedRingtone = value;
                RaisePropertyChanged(() => SelectedRingtone);
            }
        }

        private List<RingtoneModel> _ringtoneList;
        public List<RingtoneModel> RingtoneList
        {
            get { return _ringtoneList; }
            set
            {
                if (_ringtoneList == value)
                    return;

                _ringtoneList = value;
                RaisePropertyChanged(() => RingtoneList);
            }
        }

        #endregion

        #region Commands

        public ICommand SelectDaysCommand
        {
            get
            {
                return new RelayCommand((args) =>
                {
                    Messenger.Default.Send<string>("mudei com o token ", "ring");
                    //this.NavigationService.NavigateTo(ViewModelLocator.MainPageUri);
                });
            }
        }

        #endregion
    }
}
